<?php

/**
 * author wolfbian
 * date 2016-09-24
 */
use yii\helpers\Url;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use backend\components\widgets\LinkPager;
use common\models\car\CarNews;


$this->title = Yii::t('app', '汽车资讯');
$this->params['breadcrumbs'][] = $this->title;
?>
    <h1><?= Html::encode('汽车资讯') ?></h1>

<?php ActiveForm::begin(['id' => 'listform']); ?>
    <form name="listform" method="post">
        <table class="table table-striped table-bordered" style="word-wrap: break-word; table-layout: fixed">
            <tr class="header">
                <th>标题</th>
                <th>简介</th>
                <th>展示图</th>
                <th>是否开启</th>
                <th>跳转转载地址</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
        <?php foreach ($data as $value): ?>
                <tr class="hover">
                    <td><?php echo $value->title; ?></td>
                    <td><?php echo $value->simple; ?></td>
                    <td><img src="<?php echo $value->image; ?>" width="150"></td>
                    <td><?php echo CarNews::$isOpen[$value->is_open]; ?></td>
                    <td><a href="<?php echo $value->href; ?>" class="btn btn-warning" target="view_window">查看源内容</a></td>
                    <td><?php echo date('Y-m-d H:i:s', $value->created_at); ?></td>
                    <td>
                        <a href="<?php echo Url::to(['car-news-view', 'id' => $value->id, 'title' => $value->title]); ?>" class="btn btn-info" >
                            详情
                        </a>
                        <?php if ($value->is_open == 1): ?>
                            <a href="<?php echo Url::to(['car-news-is-open', 'id' => $value->id, 'is_open' => 0]); ?>" class="btn btn-danger"  onClick="return confirm('确定关闭?');">
                                关闭
                            </a>
                        <?php else: ?>
                            <a href="<?php echo Url::to(['car-news-is-open', 'id' => $value->id, 'is_open' => 1]); ?>" class="btn btn-success"  onClick="return confirm('确定开启?');">
                                开启
                            </a>
                        <?php endif; ?>
                        <a href="<?php echo Url::to(['car-news-del', 'id' => $value->id]); ?>" class="btn btn-danger"  onClick="return confirm('确定删除?');">
                            删除
                        </a>
                    </td>
                </tr>
        <?php endforeach; ?>
        </table>
        <?php ActiveForm::end(); ?>

        <?php if (empty($data)): ?>
            <div class="no-result">暂无记录</div>
        <?php endif; ?>
    </form>

<?php echo LinkPager::widget(['pagination' => $pages]); ?>
